package com.hunan.yllxy.repostitory.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hunan.yllxy.repostitory.entity.MaterialsStation;
import com.hunan.yllxy.repostitory.mapper.MaterialsStationMapper;
import com.hunan.yllxy.repostitory.dao.MaterialsStationDao;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 资料库 服务实现类
 * </p>
 *
 * @author 刘华
 * @since 2025-06-20
 */
@Service
public class MaterialsStationDaoImpl extends ServiceImpl<MaterialsStationMapper, MaterialsStation> implements MaterialsStationDao {
    @Override
    public Integer lastMaterialsStation() {
        LambdaQueryWrapper<MaterialsStation> lambdaed = Wrappers.lambdaQuery(MaterialsStation.class);
        lambdaed.orderByDesc(MaterialsStation::getSortIndex);
        lambdaed.last(" limit 1 ");
        MaterialsStation materialsStation = baseMapper.selectOne(lambdaed);
        if (materialsStation != null) {
            return materialsStation.getSortIndex()+1;
        }else {
            return 1;
        }
    }
}
